﻿using BLL.Statistics;
using Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebProject.Controllers.Base;

namespace WebProject.Controllers
{
    public class StatisticsController : Controller
    {
        StatisticsBLL sBLL;
        ProductStockBLL stockBLL;
        BLL.ChartBLL chartBLL;
        public StatisticsController()
        {
            sBLL = new StatisticsBLL();
            stockBLL = new ProductStockBLL();
            chartBLL = new BLL.ChartBLL();
        }
        /// <summary>
        /// 计划执行汇总
        /// </summary>
        /// <returns></returns>
        public ActionResult PlanDoTotal()
        {
            return View();
        }
        /// <summary>
        /// 计划执行明细汇总
        /// </summary>
        /// <returns></returns>
        public ActionResult PlanDoTotalGX()
        {
            return View();
        }
        public ActionResult SaleOrderTotal()
        {
            return View();
        }
        public ActionResult ChartBIWeb()
        {
            return View();
        }

        public ActionResult BarTrack()
        {
            return View();
        }
        public ActionResult DataShow()
        {
            return View();
        }
        public ActionResult StockInfo()
        {
            return View();
        }
        public ActionResult ChartWeb()
        {
            return View();
        }
        public ActionResult ChartWeb2()
        {
            return View();
        }
        public ActionResult ChartProduction()
        {
            return View();
        }
        public ActionResult ChartWeb3()
        {
            return View();
        }
        public ActionResult ChartWeb4()
        {
            return View();
        }

        public ActionResult ChartWeb5()
        {
            return View();
        }
        public ActionResult StockDetail()
        {
            return View();
        }
        public ActionResult BaoGongDetail()
        {
            return View();
        }
        public ActionResult PlanDoDetail()
        {
            return View();
        }
        public ActionResult HZDetail()
        {
            return View();
        }
        public ActionResult BaoGongInfo()
        {
            return View();
        }
        public ActionResult ProductWasteInfo()
        {
            return View();
        }
        public ActionResult SaleOrderProgress()
        {
            return View();
        } 
        public ActionResult CiPinTRTask()
        {
            return View();
        }
        public ActionResult AskDoTotal()
        {
            return View();
        }
        public ActionResult DataView()
        {
            return View();
        }


        /// <summary>
        /// 日生产条码统计
        /// </summary>
        /// <param name="datas"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult BarCodeDayTotal(string datas)
        {
            return Json(chartBLL.BarCodeDayTotal(datas));
        }
        

        [HttpPost]
        public JsonResult AddStockZhanYong(string info, string contents)
        {
            ProductStockBLL proBLL = new ProductStockBLL();
            return Json(proBLL.AddStockZhanYong(info, contents));
        }
        [HttpPost]
        public JsonResult DelStockZhanYong(string dataId)
        {
            ProductStockBLL proBLL = new ProductStockBLL();
            return Json(proBLL.DelStockZhanYong(dataId));
        }

     
        [HttpPost]
        public JsonResult StockCustomer()
        {
            return Json(stockBLL.StockCustomer());
        }
        [HttpPost]
        public JsonResult BarTree(string datas)
        {
            return Json(sBLL.BarCodeSoures(datas));
        }
        

          /// <summary>
          /// 获取全部班组成员
          /// </summary>
          /// <returns></returns>
          [HttpPost]
        public JsonResult GetGroupUserInfo()
        {
            BLL.Basis.ProductSetBLL pSet = new BLL.Basis.ProductSetBLL();
            return Json(pSet.GetGroupUserInfo());
        }

        
        [HttpGet]
        public JsonResult getDataList(string page, string limit, string condition, string dataType)
        {
            var rsl = new ReturnResult();
            string pageCount = "1";
            string msg = "";
            var datas = new object();
            if (dataType == "pszy")
            {
                ProductStockBLL stockBLL = new ProductStockBLL();
                rsl = stockBLL.getStockZhanYong(condition);
            }
            else if (dataType == "pstock")  //实时库存
            {
                ProductStockBLL stockBLL = new ProductStockBLL();
                rsl = stockBLL.ProductStockInfo(page, limit, ref pageCount, condition);
            }
            else if (dataType == "sdetail")   //库存明细
            {
                ProductStockBLL stockBLL = new ProductStockBLL();
                rsl = stockBLL.StockDetail(condition);
            }
           
            if (rsl.Result)
            {
                datas = rsl.Data;
            }
            else
            {
                msg = rsl.Message;
            }
            return new JsonResult()
            {
                Data = new
                {
                    count = pageCount,
                    msg = msg,
                    code = "0",
                    data = datas
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }
      

    }
}